package com.oocl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.exception.MyException;
import com.oocl.pojo.Customer;
import com.oocl.pojo.Favc;
import com.oocl.service.CustomerService;
import com.oocl.service.FavcService;
import com.oocl.service.impl.CustomerServiceFactory;
import com.oocl.service.impl.FavcServiceFactory;
import com.oocl.service.impl.ServiceFactory;

/**
 * Servlet implementation class ModifyServlet
 */
public class ModifyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		try {
			CustomerServiceFactory factory = (CustomerServiceFactory) ServiceFactory
					.getServiceFactory(CustomerServiceFactory.CUSTOMER);
			CustomerService cSer = factory.getService();
			FavcServiceFactory facytory = (FavcServiceFactory) ServiceFactory.getServiceFactory("favc");
			FavcService fSer = facytory.getService();
			List<Favc> list = fSer.getList();

			String str = request.getParameter("id");
			Integer id = Integer.parseInt(str);
			Customer c = cSer.loadCustomer(id);
			request.setAttribute("list", list);
			request.setAttribute("c", c);
			request.getRequestDispatcher("modify.jsp").forward(request, response);
		} catch (MyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
